let isStart = false, isTop = false, isTaskStart = false, isDelete = true, add_page_num = 0;
$("#table_tbody").append('<tr data-tt-id="1" id="all-task-treeTable-start"><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>');
$("#treeTable").treetable({expandable: true});
var isAlgorithmFinished = function (blockID, blockIDTr) {
    $("#" + blockIDTr + "_" + blockID + "_tr").children("td:last-child").html('<a href="javascript: void(0)" class="algorithmDetails">详情</a>');
};
let isAllAlgorithmFinished = function (blockID, temp) {
    var block = $("#" + blockID);
    block.children(".finishedNum").val(temp);
    var zhi = Math.round(temp * 100);
    var width = "width: " + zhi + "%";
    if (temp == 1) {
        block.children('.uidiv').children(".progressbar").children(".progress-bar").removeClass("progress-bar-info");
        block.children('.uidiv').children(".progressbar").children(".progress-bar").addClass("progress-bar-success");
    }
    block.children('.uidiv').children(".progressbar").children(".progress-bar").attr("style", width);
};
var combinationDrag = document.getElementById("combinationDrag");
var combinationDiv = document.getElementById("combination");
startDrag(combinationDrag, combinationDiv);
jsPlumb.ready(function () {
    var instance = window.jsp = jsPlumb.getInstance({/* default drag options*/
        DragOptions: {cursor: 'pointer', zIndex: 2000},/* the overlays to decorate each connection with.  note that the label overlay uses a function to generate the label text; in this case it returns the 'labelText' member that we set on each connection in the 'init' method below.*/
        ConnectionOverlays: [["Arrow", {
            location: 1,
            visible: true,
            width: 11,
            id: "ARROW",
            length: 11
        }], ["Label", {location: 0.1, id: "label", cssClass: "aLabel", events: {}}]],
        Container: "canvas"
    });/* this is the paint style for the connecting lines..*/
    var connectorPaintStyle = {
            strokeWidth: 2,
            stroke: "#61B7CF",
            joinstyle: "round",
            outlineStroke: "white",
            outlineWidth: 2
        },/* .. and this is the hover style.*/
        connectorHoverStyle = {strokeWidth: 3, stroke: "#61B7CF", outlineWidth: 5, outlineStroke: "white"},
        endpointHoverStyle = {fill: "#61B7CF", stroke: "#61B7CF"},/* the definition of source endpoints (the small blue ones)*/
        sourceEndpoint = {
            endpoint: "Dot",
            paintStyle: {stroke: "#61B7CF", fill: "transparent", radius: 5, strokeWidth: 1},
            isSource: true,
            connector: ["Flowchart", {stub: [10, 20], gap: 10, cornerRadius: 5, alwaysRespectStubs: true}],
            connectorStyle: connectorPaintStyle,
            hoverPaintStyle: endpointHoverStyle,
            connectorHoverStyle: connectorHoverStyle,
            maxConnections: -1,
            dragOptions: {},
            overlays: [["Label", {
                location: [0.5, 1.5],
                label: "Drag",
                cssClass: "endpointSourceLabel",
                visible: false
            }]]
        },/* the definition of target endpoints (will appear when the user drags a connection)*/targetEndpoint = {
            endpoint: "Dot",
            paintStyle: {fill: "#61B7CF", radius: 5},
            hoverPaintStyle: endpointHoverStyle,
            maxConnections: -1,
            dropOptions: {hoverClass: "hover", activeClass: "active"},
            isTarget: true,
            overlays: [["Label", {location: [0.5, -0.5], label: "Drop", cssClass: "endpointTargetLabel", visible: false}]]
        };/*渲染函数*/
    var _addEndpoints = function (toId, sourceAnchors, targetAnchors) {
        for (var i = 0; i < sourceAnchors.length; i++) {
            var sourceUUID = toId + sourceAnchors[i];
            instance.addEndpoint(toId, sourceEndpoint, {anchor: sourceAnchors[i], uuid: sourceUUID});
        }
        for (var j = 0; j < targetAnchors.length; j++) {
            var targetUUID = toId + targetAnchors[j];
            instance.addEndpoint(toId, targetEndpoint, {anchor: targetAnchors[j], uuid: targetUUID});
        }
    };
    instance.importDefaults({ConnectionsDetachable: false});
    var Hash20 = function () {
        var dataHash = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];
        var resultHsh = "";
        for (var i = 0; i < 20; i++) {
            var rHash = Math.floor(Math.random() * 62);     /*取得0-62间的随机数，目的是以此当下标取数组data里的值*/
            resultHsh += dataHash[rHash];
        }
        return resultHsh;
    }
    var combination = $("#combination");
    var url_taskHash = GetQueryString("taskHash");
    var url_taskId = GetQueryString("taskId");
    var url_modelid = GetQueryString("modelId");
    var url_taskN = GetQueryString("taskNum");
    /*加载历史任务*/
    var loadHistoryModel = function (json) {
        var lines = json.lines, blocks = json.blocks, taskNumber = json.taskNumber, htmlText = "";
        $("#taskNumber").val(taskNumber);
        $("#showTaskNum").html(taskNumber);
        $("#statusDisplay").append("，其中" + json.taskFinishedNumber + "个完成，" + json.taskStoppedNumber + "个终止，" + json.taskPauseNumber + "个暂停，" + json.taskRunningNumber + "个仍在运行。");
        for (var i in blocks) {
            var viewstyle = 'left:' + blocks[i].blockX + 'px;top:' + blocks[i].blockY + 'px;',
                viewdataid = blocks[i].isAlgorithm + "_" + blocks[i].dataId, viewid = blocks[i].blockId,
                viewClass = blocks[i].blockClass, viewName = blocks[i].blockName, viewCpuNum = blocks[i].cpuNum,
                viewTitle = blocks[i].blockTitle, viewParamNum = blocks[i].paramNum,
                viewInput = JSON.stringify(blocks[i].inputConfig), viewValue = JSON.stringify(blocks[i].paramsConfig),
                viewValueDefault = JSON.stringify(blocks[i].paramsConfigDefault);
            if (viewClass == "uiAlgorithm") {
                if (viewParamNum == 0 || (viewValue != "" && viewValue != null)) {
                    htmlText = htmlText + '<div class="' + viewClass + ' uibox" id=' + viewid + ' style=' + viewstyle + ' dataid="' + viewdataid + '">' + '<div class="uidiv"> ' + '<span class="glyphicon glyphicon-edit fleft left5"></span> ' + '<div class="progressbar progress progress-striped active">' + '<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"style="width: 100%;"></div>' + '</div>' + '</div>' + '<div class="uitext" title="' + viewTitle + '">' + viewName + '</div>' + '<input type="hidden" class="finishedNum" value="0"/>' + '<input type="hidden" class="cpuNum" id="' + viewid + 'cpuNum" value=\'' + viewCpuNum + '\'/>' + '<input type="hidden" class="paramNum" id="' + viewid + 'paramNum" value=\'' + viewParamNum + '\'/>' + '<input type="hidden" class="paramsConfig" id="' + viewid + 'params" value=\'' + viewValue + '\'/>' + '<input type="hidden" class="paramsConfigDefault" id="' + viewid + 'paramsDefault" value=\'' + viewValueDefault + '\'/>' + '<input type="hidden" class="inputConfig" id="' + viewid + 'input" value=\'' + viewInput + '\'/>' + '</div>';
                } else {
                    htmlText = htmlText + '<div class="' + viewClass + ' uibox" id=' + viewid + ' style=' + viewstyle + ' dataid="' + viewdataid + '">' + '<div class="uidiv"> ' + '<span class="glyphicon glyphicon-edit fleft left5"></span> ' + '<div class="progressbar progress progress-striped active">' + '<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"style="width: 0%;"></div>' + '</div>' + '</div>' + '<div class="uitext" title="' + viewTitle + '">' + viewName + '</div>' + '<input type="hidden" class="finishedNum" value="0"/>' + '<input type="hidden" class="cpuNum" id="' + viewid + 'cpuNum" value=\'' + viewCpuNum + '\'/>' + '<input type="hidden" class="paramNum" id="' + viewid + 'paramNum" value=\'' + viewParamNum + '\'/>' + '<input type="hidden" class="paramsConfig" id="' + viewid + 'params" value=\'' + viewValue + '\'/>' + '<input type="hidden" class="paramsConfigDefault" id="' + viewid + 'paramsDefault" value=\'' + viewValueDefault + '\'/>' + '<input type="hidden" class="inputConfig" id="' + viewid + 'input" value=\'' + viewInput + '\'/>' + '</div>';
                }
            } else if (viewClass == "uiNestModel") {
                htmlText = htmlText + '<div class="' + viewClass + ' uibox" id=' + viewid + ' style=' + viewstyle + ' dataid="' + viewdataid + '">' + '<div class="uidiv"> ' + '<span class="glyphicon glyphicon-tasks fleft left5"></span> ' + '</div>' + '<div class="uitext" title="' + viewTitle + '">' + viewName + '</div>' + '</div>';
            } else if (viewClass == "uiEnd") {
                htmlText = htmlText + '<div class="' + viewClass + ' uibox" id=' + viewid + ' style=' + viewstyle + '><div class="uitext uimid"><span class="glyphicon glyphicon-hand-up uiEnd-hand-up"></span>' + viewName + '</div></div>';
            } else if (viewClass == "uiStart") {
                htmlText = htmlText + '<div class="' + viewClass + ' uibox" id=' + viewid + ' style=' + viewstyle + '><div class="uitext uimid"><span class="glyphicon glyphicon-hand-up uiStart-hand-up"></span>' + viewName + '</div></div>';
            } else if (viewClass == "uiData") {
                htmlText = htmlText + '<div class="' + viewClass + ' uibox" id=' + viewid + ' style=' + viewstyle + '>' + '<div class="uidiv">外部数据源' + '</div>' + '<div class="uitext" id="' + viewid + '_text" title="' + viewName + '">' + viewName + '</div>' + '</div>';
            }
        }
        combination.append(htmlText);
        document.getElementById("input").value = JSON.stringify(json.inputs);
        document.getElementById("output").value = JSON.stringify(json.outputs);
        document.getElementById("other").value = JSON.stringify(json.other);/*渲染连接点*/
        $("#combination .uibox").each(function (idx, elem) {
            var $elem = $(elem), id = $elem.attr('id'), id_t = $elem.attr('id').split('_')[0];
            if (id_t == "uiStart") {
                _addEndpoints(id, ["RightMiddle"], []);
            } else if (id_t == "uiEnd") {
                _addEndpoints(id, [], ["LeftMiddle"]);
            } else if (id_t == "uiData") {
                _addEndpoints(id, ["RightMiddle"], []);
            } else {
                _addEndpoints(id, ["RightMiddle"], ["LeftMiddle"]);
            }
        });
        for (var i in lines) {
            var PageSourceId = lines[i].pageSourceId + "RightMiddle",
                PageTargetId = lines[i].pageTargetId + "LeftMiddle";
            instance.connect({uuids: [PageSourceId, PageTargetId], editable: true});
        }
    }
    /*加载*/
    var loadModel = function (json) {
        var lines = json.lines, blocks = json.blocks, taskNumber = json.taskNumber, htmlText = "";
        $("#taskNumber").val(taskNumber);
        $("#showTaskNum").html(taskNumber);
        for (var i in blocks) {
            var viewstyle = 'left:' + blocks[i].blockX + 'px;top:' + blocks[i].blockY + 'px;',
                viewdataid = blocks[i].isAlgorithm + "_" + blocks[i].dataId, viewid = blocks[i].blockId,
                viewClass = blocks[i].blockClass, viewName = blocks[i].blockName, viewCpuNum = blocks[i].cpuNum,
                viewTitle = blocks[i].blockTitle, viewParamNum = blocks[i].paramNum,
                viewInput = JSON.stringify(blocks[i].inputConfig), viewValue = JSON.stringify(blocks[i].paramsConfig),
                viewValueDefault = JSON.stringify(blocks[i].paramsConfigDefault);
            if (viewClass == "uiAlgorithm") {
                if (viewParamNum == 0 || (viewValue != "" && viewValue != null)) {
                    htmlText = htmlText + '<div class="' + viewClass + ' uibox" id=' + viewid + ' style=' + viewstyle + ' dataid="' + viewdataid + '">' + '<div class="uidiv"> ' + '<span class="glyphicon glyphicon-edit fleft left5"></span> ' + '<div class="progressbar progress progress-striped active">' + '<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"style="width: 100%;"></div>' + '</div>' + '</div>' + '<div class="uitext" title="' + viewTitle + '">' + viewName + '</div>' + '<input type="hidden" class="finishedNum" value="0"/>' + '<input type="hidden" class="cpuNum" id="' + viewid + 'cpuNum" value=\'' + viewCpuNum + '\'/>' + '<input type="hidden" class="paramNum" id="' + viewid + 'paramNum" value=\'' + viewParamNum + '\'/>' + '<input type="hidden" class="paramsConfig" id="' + viewid + 'params" value=\'' + viewValue + '\'/>' + '<input type="hidden" class="paramsConfigDefault" id="' + viewid + 'paramsDefault" value=\'' + viewValueDefault + '\'/>' + '<input type="hidden" class="inputConfig" id="' + viewid + 'input" value=\'' + viewInput + '\'/>' + '</div>';
                } else {
                    htmlText = htmlText + '<div class="' + viewClass + ' uibox" id=' + viewid + ' style=' + viewstyle + ' dataid="' + viewdataid + '">' + '<div class="uidiv"> ' + '<span class="glyphicon glyphicon-edit fleft left5"></span> ' + '<div class="progressbar progress progress-striped active">' + '<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"style="width: 0%;"></div>' + '</div>' + '</div>' + '<div class="uitext" title="' + viewTitle + '">' + viewName + '</div>' + '<input type="hidden" class="finishedNum" value="0"/>' + '<input type="hidden" class="cpuNum" id="' + viewid + 'cpuNum" value=\'' + viewCpuNum + '\'/>' + '<input type="hidden" class="paramNum" id="' + viewid + 'paramNum" value=\'' + viewParamNum + '\'/>' + '<input type="hidden" class="paramsConfig" id="' + viewid + 'params" value=\'' + viewValue + '\'/>' + '<input type="hidden" class="paramsConfigDefault" id="' + viewid + 'paramsDefault" value=\'' + viewValueDefault + '\'/>' + '<input type="hidden" class="inputConfig" id="' + viewid + 'input" value=\'' + viewInput + '\'/>' + '</div>';
                }
            } else if (viewClass == "uiNestModel") {
                htmlText = htmlText + '<div class="' + viewClass + ' uibox" id=' + viewid + ' style=' + viewstyle + ' dataid="' + viewdataid + '">' + '<div class="uidiv"> ' + '<span class="glyphicon glyphicon-tasks fleft left5"></span> ' + '</div>' + '<div class="uitext" title="' + viewTitle + '">' + viewName + '</div>' + '</div>';
            } else if (viewClass == "uiEnd") {
                htmlText = htmlText + '<div class="' + viewClass + ' uibox" id=' + viewid + ' style=' + viewstyle + '><div class="uitext uimid"><span class="glyphicon glyphicon-hand-up uiEnd-hand-up"></span>' + viewName + '</div></div>';
            } else if (viewClass == "uiStart") {
                htmlText = htmlText + '<div class="' + viewClass + ' uibox" id=' + viewid + ' style=' + viewstyle + '><div class="uitext uimid"><span class="glyphicon glyphicon-hand-up uiStart-hand-up"></span>' + viewName + '</div></div>';
            } else if (viewClass == "uiData") {
                htmlText = htmlText + '<div class="' + viewClass + ' uibox" id=' + viewid + ' style=' + viewstyle + '>' + '<div class="uidiv">外部数据源' + '</div>' + '<div class="uitext uimid" id="' + viewid + '_text" title="' + viewName + '">' + viewName + '</div>' + '</div>';
            }
        }
        combination.append(htmlText);
        document.getElementById("data").value = JSON.stringify(json.data);/*渲染连接点*/
        $("#combination .uibox").each(function (idx, elem) {
            var $elem = $(elem), id = $elem.attr('id'), id_t = $elem.attr('id').split('_')[0];
            if (id_t == "uiStart") {
                _addEndpoints(id, ["RightMiddle"], []);
            } else if (id_t == "uiEnd") {
                _addEndpoints(id, [], ["LeftMiddle"]);
            } else if (id_t == "uiData") {
                _addEndpoints(id, ["RightMiddle"], []);
            } else {
                _addEndpoints(id, ["RightMiddle"], ["LeftMiddle"]);
            }
        });
        for (var i in lines) {
            var PageSourceId = lines[i].pageSourceId + "RightMiddle",
                PageTargetId = lines[i].pageTargetId + "LeftMiddle";
            instance.connect({uuids: [PageSourceId, PageTargetId], editable: true});
        }
    }
    if (url_taskHash != null) {
        $.ajax({
            url: constUrl + "ws/task/complexHistoryResult",
            type: 'post',
            data: {"taskHash": url_taskHash},
            dataType: 'json',
            xhrFields: {withCredentials: true},
            crossDomain: true,
            success: function (responseText) {
                var jsondata = responseText.json;
                var name = responseText.taskName;
                var taskhash = document.getElementById("taskhash");
                taskhash.value = url_taskHash;
                $("#taskname").html("任务名：" + name);
                $("#all-task-treeTable-start").children('td').eq(0).html("任务：" + name);
                var state = responseText.taskState;
                if (state == "1") {/*运行中*/
                    $('#button_start').attr("disabled", true);
                    $('#button_start').css("display", "none");
                    $('#button_continue').attr("disabled", true);
                    $('#button_continue').css("display", "inline-block");
                    $('#button_stop').attr("disabled", false);
                    $('#button_over').attr("disabled", false);
                    $('#button_save').attr("disabled", true);
                    isStart = true;
                    communicate();
                    receiveJobs();
                } else if (state == "2") {/*暂停*/
                    $('#button_start').attr("disabled", true);
                    $('#button_start').css("display", "none");
                    $('#button_continue').attr("disabled", false);
                    $('#button_continue').css("display", "inline-block");
                    $('#button_stop').attr("disabled", true);
                    $('#button_over').attr("disabled", true);
                    $('#button_save').attr("disabled", true);
                    isStart = false;
                } else if (state == "3") {/*终止*/
                    $('#button_start').attr("disabled", true);
                    $('#button_start').css("display", "inline-block");
                    $('#button_continue').css("display", "none");
                    $('#button_continue').attr("disabled", true);
                    $('#button_stop').attr("disabled", true);
                    $('#button_over').attr("disabled", true);
                    $('#button_save').attr("disabled", true);
                    isStart = false;
                } else if (state == "4") {/*完成*/
                    $('#button_start').attr("disabled", true);
                    $('#button_start').css("display", "inline-block");
                    $('#button_continue').css("display", "none");
                    $('#button_continue').attr("disabled", true);
                    $('#button_stop').attr("disabled", true);
                    $('#button_over').attr("disabled", true);
                    $('#button_save').attr("disabled", true);
                    isStart = false;
                }
                var strState = responseText.state;
                $('#task_info_pre').append(strState);
                $('#task_info_pre').scrollTop($('#task_info_pre')[0].scrollHeight);
                $("#displayBox").css("display", "block");
                if (jsondata.hasOwnProperty("other")) {
                    $("#otherPriority").html(jsondata.other[0].Priority);
                    if (jsondata.other[0].ParallelStrategy == "ut") {
                        $("#otherParallelStrategy").html("按CPU可利用率最大");
                    } else if (jsondata.other[0].ParallelStrategy == "-ut") {
                        console.log(jsondata.other[0].ParallelStrategy);
                        $("#otherParallelStrategy").html("按CPU可利用率最小");
                    } else if (jsondata.other[0].ParallelStrategy == "mem") {
                        $("#otherParallelStrategy").html("按内存剩余最大");
                    } else if (jsondata.other[0].ParallelStrategy == "-mem") {
                        $("#otherParallelStrategy").html("按内存剩余最小");
                    } else {
                        $("#otherParallelStrategy").html("未知");
                    }
                }
                var tbody = "";
                if (jsondata.hasOwnProperty("taskNumber")) {
                    var taskNum = jsondata.taskNumber;
                    $("#taskNumber").val(taskNum);
                    $("#showTaskNum").val(taskNum);
                }
                var one_tbody = "";
                if (jsondata.hasOwnProperty("inputs") && jsondata.hasOwnProperty("outputs")) {
                    for (var i = 0; i < taskNum && i < 10; i++) {
                        var input = jsondata.inputs[i].input;
                        var output = jsondata.outputs[i];
                        var data = jsondata.inputs[i].data;
                        one_tbody = "";
                        if (data != "" && data != null) {
                            for (var n = 0; n < input.length; n++) {
                                if (n == 0) {
                                    one_tbody += '<tr class="tr_input"><td rowspan="' + (input.length + data.length) + '" class="am-text-middle">输入</td><td class="blockName" title="' + input[n].blockName + '">' + input[n].blockName + '</td><td class="input_name" title="' + input[n].inputName + '">' + input[n].inputName + '</td><td class="input_input" title="' + input[n].frontOutput.frontOutputName + '">' + input[n].frontOutput.frontOutputName + '</td></tr>';
                                } else {
                                    one_tbody += '<tr class="tr_input"><td class="blockName" title="' + input[n].blockName + '">' + input[n].blockName + '</td><td class="input_name" title="' + input[n].inputName + '">' + input[n].inputName + '</td><td class="input_input" title="' + input[n].frontOutput.frontOutputName + '">' + input[n].frontOutput.frontOutputName + '</td></tr>';
                                }
                            }
                            for (var m = 0; m < data.length; m++) {
                                one_tbody += '<tr class="tr_data"><td class="blockName" title="' + data[m].dataBlockName + '">' + data[m].dataBlockName + '</td><td class="input_name" title="' + data[m].dataName.split("+")[0] + '">' + data[m].dataName.split("+")[0] + '</td><td class="input_input" title="' + data[m].dataValue + '">' + data[m].dataValue + '</td></tr>';
                            }
                        } else {
                            for (var n = 0; n < input.length; n++) {
                                if (n == 0) {
                                    one_tbody += '<tr class="tr_input"><td rowspan="' + (input.length) + '" class="am-text-middle">输入</td><td class="blockName" title="' + input[n].blockName + '">' + input[n].blockName + '</td><td class="input_name" title="' + input[n].inputName + '">' + input[n].inputName + '</td><td class="input_input" title="' + input[n].frontOutput.frontOutputName + '">' + input[n].frontOutput.frontOutputName + '</td></tr>';
                                } else {
                                    one_tbody += '<tr class="tr_input"><td class="blockName" title="' + input[n].blockName + '">' + input[n].blockName + '</td><td class="input_name" title="' + input[n].inputName + '">' + input[n].inputName + '</td><td class="input_input" title="' + input[n].frontOutput.frontOutputName + '">' + input[n].frontOutput.frontOutputName + '</td></tr>';
                                }
                            }
                        }
                        for (var o = 0; o < output.length; o++) {
                            if (o == 0) {
                                one_tbody += '<tr class="tr_output"><td rowspan="' + output.length + '" class="am-text-middle">输出</td><td class="blockName" title="' + output[o].blockName + '">' + output[o].blockName + '</td><td class="output_name" title="' + output[o].outputName + '">' + output[o].outputName + '</td><td class="output_output" title="' + output[o].outputAddress + output[o].outputValue + '">' + output[o].outputAddress + output[o].outputValue + '</td></tr>';
                            } else {
                                one_tbody += '<tr class="tr_output"><td class="blockName" title="' + output[o].blockName + '">' + output[o].blockName + '</td><td class="output_name" title="' + output[o].outputName + '">' + output[o].outputName + '</td><td class="output_output" title="' + output[o].outputAddress + output[o].outputValue + '">' + output[o].outputAddress + output[o].outputValue + '</td></tr>';
                            }
                        }
                        one_tbody = "<tbody class='table_body'>" + one_tbody + "</tbody>";
                        tbody += one_tbody;
                    }
                }
                $("#displayTable").append(tbody);
                loadHistoryModel(jsondata);/*设置进度为空*/
                $(".progress-bar").each(function (index, elem) {
                    var $elem = $(elem);
                    $elem.attr("style", "width: 0%");
                });
                /*加载表单任务算法顺序*/
                let cx_taskHash = document.getElementById("taskhash").value;
                add_page_num += 1;
                $.ajax({
                    url: constUrl + "GetBlockState",
                    type: 'post',
                    timeout: 60000,
                    data: {
                        "taskHash": cx_taskHash,
                        "onePageCount": 10,
                        "currentPage": 1,
                        "waitTime": 0
                    },
                    xhrFields: {withCredentials: true},
                    crossDomain: true,
                    dataType: 'json',
                    success: function (responseText) {
                        if (responseText.finishedRatio == 1) {
                            $('#task_info_pre').scrollTop($('#task_info_pre')[0].scrollHeight);
                            $('#button_start').attr("disabled", true);
                            $('#button_start').css("display", "none");
                            $('#button_continue').attr("disabled", true);
                            $('#button_continue').css("display", "inline-block");
                            $('#button_stop').attr("disabled", true);
                            $('#button_over').attr("disabled", true);
                            $('#button_save').attr("disabled", true);
                            isStart = false;
                        }
                        let temp_1_parent = $("#treeTable").treetable("node", "1");
                        $("#treeTable").treetable("unloadBranch", temp_1_parent);
                        var subTaskHash = responseText.result;
                        var orders = responseText.algorithmOrder;
                        let temp_i_parent = $("#treeTable").treetable("node", "1");
                        for (var i = 0; i < subTaskHash.length; i++) {
                            $("#treeTable").treetable("loadBranch", temp_i_parent, '<tr data-tt-id="1-' + parseInt(i + 1) + '" data-tt-parent-id="1" id="' + subTaskHash[i].taskHash + '_tr"><td>任务：' + parseInt(i + 1) + '</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>');
                            let temp_j_parent =  $("#treeTable").treetable("node", "1-" + parseInt(i + 1));
                            for (var j = 0; j < orders.length; j++) {
                                $("#treeTable").treetable("loadBranch", temp_j_parent, '<tr data-tt-id="1-' + parseInt(i + 1) + '-' + parseInt(j + 1) + '" data-tt-parent-id="1-' + parseInt(i + 1) + '" id="' + subTaskHash[i].taskHash + '_' + orders[j].blockId + '_tr" task-id="' + subTaskHash[i].taskHash + '" block-id="' + orders[j].blockId + '"><td>算法名：' + orders[j].algorithmName + '</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>');
                            }
                        }
                        $("#treeTable").treetable("expandAll");
                        console.log(responseText.result.length);
                        for (var i = 0; i < responseText.result.length; i++) {
                            var json = responseText.result[i];
                            if (json.state == "DONE") {
                                $("#" + json.taskHash + "_tr").children('td').eq(6).html("完成");
                                $("#" + json.taskHash + "_tr").addClass("am-success");
                            } else if (json.state == "ERROR") {
                                $("#" + json.taskHash + "_tr").children('td').eq(6).html("失败");
                                $("#" + json.taskHash + "_tr").addClass("am-danger");
                            } else if (json.state == "STOP") {
                                $("#" + json.taskHash + "_tr").children('td').eq(6).html("终止");
                                $("#" + json.taskHash + "_tr").addClass("am-danger");
                            } else if (json.state == "PAUSE") {
                                $("#" + json.taskHash + "_tr").children('td').eq(6).html("暂停");
                                $("#" + json.taskHash + "_tr").addClass("am-danger");
                            } else if (json.state == "RUN" || json.state == "PEND") {
                            } else {
                            }
                            if (json.detail != null) {
                                for (var j = 0; j < json.detail.length; j++) {
                                    var jobJson = json.detail[j];
                                    var data_tt_parent_id = $("#" + json.taskHash + "_" + jobJson.blockId + "_tr").attr("data-tt-id");
                                    var state = "";
                                    var temp_tr = '';/* $("#"+jobJson.id).remove();*/
                                    if (jobJson.isSuccess == "DONE") {
                                        state = "成功";
                                        temp_tr = '<tr id="' + jobJson.id + '" data-tt-id="' + data_tt_parent_id + '-' + jobJson.jobIndex + '" data-tt-parent-id="' + data_tt_parent_id + '" class="am-primary" block-id="' + jobJson.blockId + '" task-id="' + json.taskHash + '">' + '<td>作业' + jobJson.jobIndex + '</td>' + '<td>' + jobJson.id + '</td>' + '<td>' + jobJson.name + '</td>' + '<td>' + jobJson.commitTime + '</td>' + '<td>' + jobJson.endTime + '</td>' + '<td>' + jobJson.priority + '</td>' + '<td>' + state + '</td>' + '<td><a href="javascript: void(0)" class="jobDetails">详情</a> <a href="javascript: void(0)" class="jobRefresh">刷新</a></td>' + '</tr>';
                                    } else if (jobJson.isSuccess == "PAUSE") {
                                        state = "暂停";
                                        temp_tr = '<tr id="' + jobJson.id + '" data-tt-id="' + data_tt_parent_id + '-' + jobJson.jobIndex + '" data-tt-parent-id="' + data_tt_parent_id + '" class="am-active" block-id="' + jobJson.blockId + '" task-id="' + json.taskHash + '">' + '<td>作业' + jobJson.jobIndex + '</td>' + '<td>' + jobJson.id + '</td>' + '<td>' + jobJson.name + '</td>' + '<td>' + jobJson.commitTime + '</td>' + '<td>' + jobJson.endTime + '</td>' + '<td>' + jobJson.priority + '</td>' + '<td>' + state + '</td>' + '<td><a href="javascript: void(0)" class="jobDetails">详情</a> <a href="javascript: void(0)" class="jobRefresh">刷新</a></td>' + '</tr>';
                                    } else if (jobJson.isSuccess == "STOP") {
                                        state = "终止";
                                        temp_tr = '<tr id="' + jobJson.id + '" data-tt-id="' + data_tt_parent_id + '-' + jobJson.jobIndex + '" data-tt-parent-id="' + data_tt_parent_id + '" class="am-warning" block-id="' + jobJson.blockId + '" task-id="' + json.taskHash + '">' + '<td>作业' + jobJson.jobIndex + '</td>' + '<td>' + jobJson.id + '</td>' + '<td>' + jobJson.name + '</td>' + '<td>' + jobJson.commitTime + '</td>' + '<td>' + jobJson.endTime + '</td>' + '<td>' + jobJson.priority + '</td>' + '<td>' + state + '</td>' + '<td><a href="javascript: void(0)" class="jobDetails">详情</a> <a href="javascript: void(0)" class="jobRefresh">刷新</a></td>' + '</tr>';
                                    } else if (jobJson.isSuccess == "ERROR") {
                                        state = "";
                                        temp_tr = '<tr id="' + jobJson.id + '" data-tt-id="' + data_tt_parent_id + '-' + jobJson.jobIndex + '" data-tt-parent-id="' + data_tt_parent_id + '" class="am-danger" block-id="' + jobJson.blockId + '" task-id="' + json.taskHash + '">' + '<td>作业' + jobJson.jobIndex + '</td>' + '<td>' + jobJson.id + '</td>' + '<td>' + jobJson.name + '</td>' + '<td>' + jobJson.commitTime + '</td>' + '<td>' + jobJson.endTime + '</td>' + '<td>' + jobJson.priority + '</td>' + '<td>' + state + '</td>' + '<td><a href="javascript: void(0)" class="jobDetails">详情</a> <a href="javascript: void(0)" class="jobRefresh">刷新</a></td>' + '</tr>';
                                    } else {
                                        state = "";
                                        temp_tr = '<tr id="' + jobJson.id + '" data-tt-id="' + data_tt_parent_id + '-' + jobJson.jobIndex + '" data-tt-parent-id="' + data_tt_parent_id + '" class="am-danger" block-id="' + jobJson.blockId + '" task-id="' + json.taskHash + '">' + '<td>作业' + jobJson.jobIndex + '</td>' + '<td>' + jobJson.id + '</td>' + '<td>' + jobJson.name + '</td>' + '<td>' + jobJson.commitTime + '</td>' + '<td>' + jobJson.endTime + '</td>' + '<td>' + jobJson.priority + '</td>' + '<td>' + state + '</td>' + '<td><a href="javascript: void(0)" class="jobDetails">详情</a> <a href="javascript: void(0)" class="jobRefresh">刷新</a></td>' + '</tr>';
                                    }
                                    console.log("detail:xx.properties");
                                    var node = $("#treeTable").treetable("node", data_tt_parent_id);
                                    $("#treeTable").treetable("loadBranch", node, temp_tr);
                                    $("#treeTable").treetable("expandNode", "1");
                                    $("#treeTable").treetable("expandNode", data_tt_parent_id);
                                    if (jobJson.isAlgorithmFinished == 1)
                                        isAlgorithmFinished(jobJson.blockId, jobJson.id)
                                }
                            }
                        }
                        for (let ii = 0; ii<responseText.algorithmOrder.length; ii++){
                            isAllAlgorithmFinished(responseText.algorithmOrder[ii].blockId, responseText.algorithmOrder[ii].finishedRatio);
                        }
                        addPageNum(parseInt(responseText.pageNum));
                        paginationInit();
                        receiveJobs(1, 10, add_page_num);
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        if (textStatus == "timeout") {/*超时间*/
                            receiveJobs(1, 10, current_add_page_num);
                        }
                    }
                })

                var printData = responseText.state;
                for (var n = 0; n < printData.length; n++) {
                    var rT = printData[n].state;
                    $('#task_info_pre').append(rT);
                    $('#task_info_pre').scrollTop($('#task_info_pre')[0].scrollHeight);
                    $("#treeTable").treetable("expandAll");
                }
            },
            complete: function () {
            },
            error: function () {
            }
        })
    }
    else if (url_taskId != null) {
        $.ajax({
            url: constUrl + "ws/task/list",
            type: 'post',
            data: {"operateType": "showTaskById", "taskId": url_taskId},
            dataType: 'json',
            success: function (responseText) {
                console.log(new Date());
                var jsondata = JSON.parse(responseText.result[0].json);
                var name = responseText.result[0].name;
                var taskid = document.getElementById("taskid");
                $("#input").val(JSON.stringify(jsondata.inputs));
                $("#output").val(JSON.stringify(jsondata.outputs));
                $("#other").val(JSON.stringify(jsondata.other));
                $("#taskname").html("任务名：" + name);
                $("#all-task-treeTable-start").children('td').eq(0).html("任务：" + name);
                $("#taskhash").val("null");
                $("#displayBox").css("display", "block");
                $("#otherPriority").html(jsondata.other[0].Priority);
                if (jsondata.other[0].ParallelStrategy == "ut") {
                    $("#otherParallelStrategy").html("按CPU可利用率最大");
                } else if (jsondata.other[0].ParallelStrategy == "-ut") {
                    console.log(jsondata.other[0].ParallelStrategy);
                    $("#otherParallelStrategy").html("按CPU可利用率最小");
                } else if (jsondata.other[0].ParallelStrategy == "mem") {
                    $("#otherParallelStrategy").html("按内存剩余最大");
                } else if (jsondata.other[0].ParallelStrategy == "-mem") {
                    $("#otherParallelStrategy").html("按内存剩余最小");
                } else {
                    $("#otherParallelStrategy").html("未知");
                }
                var taskNum = jsondata.taskNumber;
                $("#taskNumber").val(taskNum);
                $("#showTaskNum").val(taskNum);
                var tbody = "";
                var one_tbody = "";
                for (var i = 0; i < taskNum && i < 10; i++) {
                    var input = jsondata.inputs[i].input;
                    var output = jsondata.outputs[i];
                    var data = jsondata.inputs[i].data;
                    one_tbody = "";
                    if (data != "" && data != null) {
                        for (var n = 0; n < input.length; n++) {
                            if (n == 0) {
                                one_tbody += '<tr class="tr_input"><td rowspan="' + (input.length + data.length) + '" class="am-text-middle">输入</td><td class="blockName" title="' + input[n].blockName + '">' + input[n].blockName + '</td><td class="input_name" title="' + input[n].inputName + '">' + input[n].inputName + '</td><td class="input_input" title="' + input[n].frontOutput.frontOutputName + '">' + input[n].frontOutput.frontOutputName + '</td></tr>';
                            } else {
                                one_tbody += '<tr class="tr_input"><td class="blockName" title="' + input[n].blockName + '">' + input[n].blockName + '</td><td class="input_name" title="' + input[n].inputName + '">' + input[n].inputName + '</td><td class="input_input" title="' + input[n].frontOutput.frontOutputName + '">' + input[n].frontOutput.frontOutputName + '</td></tr>';
                            }
                        }
                        for (var m = 0; m < data.length; m++) {
                            one_tbody += '<tr class="tr_data"><td class="blockName" title="' + data[m].dataBlockName + '">' + data[m].dataBlockName + '</td><td class="input_name" title="' + data[m].dataName.split("+")[0] + '">' + data[m].dataName.split("+")[0] + '</td><td class="input_input" title="' + data[m].dataValue + '">' + data[m].dataValue + '</td></tr>';
                        }
                    } else {
                        for (var n = 0; n < input.length; n++) {
                            if (n == 0) {
                                one_tbody += '<tr class="tr_input"><td rowspan="' + (input.length) + '" class="am-text-middle">输入</td><td class="blockName" title="' + input[n].blockName + '">' + input[n].blockName + '</td><td class="input_name" title="' + input[n].inputName + '">' + input[n].inputName + '</td><td class="input_input" title="' + input[n].frontOutput.frontOutputName + '">' + input[n].frontOutput.frontOutputName + '</td></tr>';
                            } else {
                                one_tbody += '<tr class="tr_input"><td class="blockName" title="' + input[n].blockName + '">' + input[n].blockName + '</td><td class="input_name" title="' + input[n].inputName + '">' + input[n].inputName + '</td><td class="input_input" title="' + input[n].frontOutput.frontOutputName + '">' + input[n].frontOutput.frontOutputName + '</td></tr>';
                            }
                        }
                    }
                    for (var o = 0; o < output.length; o++) {
                        if (o == 0) {
                            one_tbody += '<tr class="tr_output"><td rowspan="' + output.length + '" class="am-text-middle">输出</td><td class="blockName" title="' + output[o].blockName + '">' + output[o].blockName + '</td><td class="output_name" title="' + output[o].outputName + '">' + output[o].outputName + '</td><td class="output_output" title="' + output[o].outputAddress + output[o].outputValue + '">' + output[o].outputAddress + output[o].outputValue + '</td></tr>';
                        } else {
                            one_tbody += '<tr class="tr_output"><td class="blockName" title="' + output[o].blockName + '">' + output[o].blockName + '</td><td class="output_name" title="' + output[o].outputName + '">' + output[o].outputName + '</td><td class="output_output" title="' + output[o].outputAddress + output[o].outputValue + '">' + output[o].outputAddress + output[o].outputValue + '</td></tr>';
                        }
                    }
                    one_tbody = "<tbody class='table_body'>" + one_tbody + "</tbody>";
                    tbody += one_tbody;
                }
                $("#displayTable").append(tbody);
                taskid.value = url_taskId;
                $('#button_start').attr("disabled", false);
                $('#button_continue').css("display", "none");
                $('#button_continue').attr("disabled", true);
                $('#button_stop').attr("disabled", true);
                $('#button_over').attr("disabled", true);
                $('#button_save').attr("disabled", true);
                console.log(new Date());
                loadModel(jsondata);
                console.log(new Date());
            },
            complete: function () {
            },
            error: function () {
            }
        })
    }
    else if (url_modelid != null) {
        document.getElementById("modelid").value = url_modelid;
        $.ajax({
            url: constUrl + "ws/task/list",
            type: 'post',
            data: {"operateType": "getJsonByModelId", "modelId": url_modelid},
            dataType: 'json',
            success: function (responseText) {
                var jsondata = responseText.json.json;
                var name = responseText.json.name;
                $("#taskname").html("模型名：" + name);
                $("#all-task-treeTable-start").children('td').eq(0).html("任务：" + name);
                $('#button_start').attr("disabled", true);
                $('#button_continue').css("display", "none");
                $('#button_continue').attr("disabled", true);
                $('#button_stop').attr("disabled", true);
                $('#button_over').attr("disabled", true);
                $('#button_save').attr("disabled", false);
                loadModel(jsondata);
                $("#taskNumber").val(url_taskN);
                $("#showTaskNum").html(url_taskN);
            },
            complete: function () {
            },
            error: function () {
            }
        })
    }
    /*打开单个job详细信息*/
    $("#table_tbody").on("click", ".jobDetails", function () {
        var $this = $(this).parent().parent();
        var jodid = $this.children('td').eq(1).html();
        var blockid = $this.attr("block-id");
        var taskid = $this.attr("task-id");
        $("#jobid").val(jodid);
        $("#jobblockid").val(blockid);
        $("#jobtaskid").val(taskid);
        layer.open({
            type: 2,
            skin: 'layui-layer-lan',
            title: '作业详情',
            fix: false,
            scrollbar: false,
            shadeClose: true,
            maxmin: true,
            area: ['659px', '80%'],
            content: constUrl + 'views/task/detail.action'
        });
    });
    /*更新单个job状态*/
    $("#table_tbody").on("click", ".jobRefresh", function () {
        var $this = $(this).parent().parent();
        var jodid = $this.children('td').eq(1).html();
        var blockid = $this.attr("block-id");
        var taskid = $this.attr("task-id");
        $.ajax({
            url: constUrl + "ws/job/state",
            type: 'post',
            data: {"jobId": jodid, "blockId": blockid, "taskHash": taskid, "operate": "refresh"},
            dataType: 'json',
            success: function (responseText) {
                if (responseText.result == "true") {
                    layer.alert("刷新成功！");
                } else if (responseText.result == "false") {
                    layer.alert("刷新失败！");
                } else {
                    layer.alert("作业已完成，无法进行刷新！");
                }
            }
        });
    });
    /*打开单个算法详细信息*/
    $("#table_tbody").on("click", ".algorithmDetails", function () {
        if (isDelete) {
            var $this = $(this).parent().parent();
            $.ajax({
                url: constUrl + "ws/job/state",
                type: 'post',
                data: {"taskHash": $this.attr("task-id"), "blockId": $this.attr("block-id"), "operate": "88"},
                dataType: 'json',
                success: function (responseText) {
                    parent.$("body").append('<div id="element" class="element"></div>');
                    var options = {
                        circle_radius: 220,
                        normal_feature_size: 100,
                        highlighted_feature_size: 150,
                        top_margin: 100,
                        bottom_margin: 50,
                        spacing: 40,
                        min_padding: 50,
                        heading_font_size: 30,
                        description_font_size: 20,
                        type: 'image'
                    };
                    var settings = new Array();
                    json = responseText;
                    for (var i = 0; i < json.length; i++) {
                        var json_one = json[i].fullInfo;
                        var img_num = i % 6 + 1;
                        var setting = {
                            image: constUrl + 'assets/img/zzsc' + img_num + '.png',
                            heading: "作业名：" + json_one.jobName,
                            description: '<table class="am-table am-table-bordered am-table-radius am-table-striped" style="width: 600px"><tr id="job_id" class="info"><td style="width: 170px">作业ID</td><td>' + json_one.jobId + '</td></tr><tr id="owner" ><td>节点名称</td><td>' + json_one.executionHost + '</td></tr><tr id="queue" class="info"><td>作业队列</td><td>' + json_one.queue + '</td></tr><tr id="requestGpuNum" ><td>GPU个数</td><td>' + json_one.requestGpuNum + '</td></tr><tr id="bindGPU" class="info"><td>GPU信息</td><td>' + json_one.bindGPU + '</td></tr><tr id="reasons" ><td>错误描述</td><td>' + json_one.reasons + '</td></tr><tr id="sumRusage" class="info"><td>机器信息</td><td>' + JSON.stringify(json_one.sumRusage) + '</td></tr><tr id="outFile" ><td>日志存储位置</td><td>' + json_one.outFile + '</td></tr><tr id="maxNumProcessors" class="info"><td>最大cpu数</td><td>' + json_one.maxNumProcessors + '</td></tr><tr id="numProcessors" class="info"><td>最小cpu数</td><td>' + json_one.numProcessors + '</td></tr><tr id="submitTime" class="info"><td>作业提交时间</td><td>' + json_one.submitTime + '</td></tr></table>'
                        };
                        settings.push(setting);
                    }
                    var fp = new FeaturePresenter(parent.$("#element"), settings, options);
                    fp.createPresenter();
                    parent.$("#element").append('<span class="glyphicon glyphicon-remove removeElement" aria-hidden="true"></span>');
                    parent.$(".feature-presenter-circle-container").attr("id", "feature-presenter-circle-container");
                    parent.$(".feature-presenter-text-container").attr("id", "feature-presenter-text-container");
                    parent.$("#element").on("click", ".removeElement", function () {
                        $(this).parent("div[id='element']").slideUp(1000, function () {
                            $(this).remove();
                            isDelete = true;
                        })
                    });
                    parent.$("#element").on("click", function (e) {
                        var e = e || window.event; /*浏览器兼容性*/
                        var elem = e.target || e.srcElement;
                        while (elem) { /*循环判断至跟节点，防止点击的是div子元素*/
                            console.log(elem.id);
                            if (elem.id == 'feature-presenter-circle-container' || elem.id == "feature-presenter-text-container") {
                                return;
                            }
                            if (elem.id == "element") {
                                break;
                            }
                            elem = elem.parentNode;
                        }
                        $(this).slideUp(1000, function () {
                            $(this).remove();
                            isDelete = true;
                        })
                    });
                    isDelete = false;
                },
                complete: function () {
                },
                error: function () {
                }
            });
        } else {
            layer.msg('请不要连续点击！');
        }
    });
    /*编辑详细参数*/
    $(combination).on("click", ".glyphicon-edit", function () {
        var isTaskHash = document.getElementById('taskhash').value;
        if (isTaskHash == "") {
            $("#allowModification").val(true);
        } else {
            $("#allowModification").val(false);
        }
        var $this = $(this).parent().parent();
        document.getElementById('cpuNum').value = $this.children(".cpuNum").val();
        document.getElementById('blockid').value = $this.attr("id");
        document.getElementById('algorithmid').value = $this.attr("dataid").split("_")[1];
        var frontAlgorithmIds = [];
        var algorithmid = "";
        var blockName = "";
        $.each(instance.getAllConnections(), function (idx, connection) {
            algorithmid = "";
            if (connection.targetId == document.getElementById('blockid').value) {
                $("#combination .uibox").each(function (idx, elem) {
                    var $elem = $(elem);
                    if (connection.sourceId == $elem.attr('id') && $elem.attr('dataId') != null) {
                        algorithmid = $elem.attr('dataId').split("_")[1];
                        blockName = $elem.children('.uitext').text();
                    }
                });
                frontAlgorithmIds.push({blockId: connection.sourceId, blockName: blockName, algorithmId: algorithmid});
            }
        });
        var qz_jsonData = JSON.stringify(frontAlgorithmIds);
        $("#frontAlgorithmIds").val(qz_jsonData);
        layer.open({
            type: 2,
            skin: 'layui-layer-lan',
            title: '算法配置',
            fix: false,
            scrollbar: false,
            shadeClose: false,
            maxmin: true,
            area: ['500px', '80%'],
            content: constUrl + 'views/task/set/algorithm.action'
        });
    });
    /*输入文件配置以及优先级和策略*/
    $(combination).on("click", ".uiStart-hand-up", function () {
        var isTaskHash = document.getElementById('taskhash').value;
        var datas = [];
        if (isTaskHash == "") {
            $("#allowModification").val(true);
        } else {
            $("#allowModification").val(false);
        }
        $.each(instance.getAllConnections(), function (idx, connection) {
            if (connection.sourceId.split("_")[0] == "uiData") {
                $("#combination .uibox").each(function (idx, elem) {
                    var $elem = $(elem);
                    if (connection.targetId == $elem.attr('id') && $elem.attr('dataId') != null) {
                        var data = $elem.children(".inputConfig").val();
                        var json_data = eval("(" + data + ")");
                        for (var i = 0; i < json_data.length; i++) {
                            if (JSON.stringify(json_data[i].frontOutput.frontOutputName.split("+")[1]) != "" && JSON.stringify(json_data[i].frontOutput.frontOutputName.split("+")[1]) != "undefined" && json_data[i].frontOutput.frontOutputName.split("+")[1] != null) {
                                datas.push({
                                    dataName: json_data[i].frontOutput.frontOutputName.split("+")[0],
                                    dataBlockId: json_data[i].frontOutput.frontOutputName.split("+")[1],
                                    dataNumber: json_data[i].frontOutput.frontOutputName.split("+")[2],
                                    Name: $("#" + connection.sourceId).children(".uitext").html(),
                                    type: json_data[i].frontOutput.type
                                });
                            }
                        }
                    }
                });
            }
        });
        $("#datas").val(JSON.stringify(datas));
        var algorithmid = "";
        var blockName = "";
        var startSetting = [];
        $.each(instance.getAllConnections(), function (idx, connection) {
            if (connection.sourceId == "uiStart_1") {
                $("#combination .uibox").each(function (idx, elem) {
                    var $elem = $(elem);
                    if (connection.targetId == $elem.attr('id') && $elem.attr('dataId') != null) {
                        algorithmid = $elem.attr('dataId').split("_")[1];
                        console.log(algorithmid);
                        blockName = $elem.children('.uitext').text();
                    }
                });
                startSetting.push({blockId: connection.targetId, blockName: blockName, algorithmId: algorithmid,});
            }
        });
        $("#startSetting").val(JSON.stringify(startSetting));
        layer.open({
            type: 2,
            skin: 'layui-layer-lan',
            title: '任务输入配置',
            fix: false,
            scrollbar: false,
            shadeClose: false,
            maxmin: true,
            area: ['800px', '80%'],
            content: constUrl + 'views/task/set/start.action',
            cancel: function (index, layero) {
                if (confirm('确认放弃保存并关闭当前界面？')) { /*只有当点击confirm框的确定时，该层才会关闭*/
                    layer.close(index)
                }
                return false;
            }
        });
    });
    /*输出文件配置*/
    $(combination).on("click", ".uiEnd-hand-up", function () {
        var isTaskHash = document.getElementById('taskhash').value;
        if (isTaskHash == "") {
            $("#allowModification").val(true);
        } else {
            $("#allowModification").val(false);
        }
        var $this = $(this).parent().parent();
        document.getElementById('blockid').value = $this.attr("id");
        document.getElementById('algorithmid').value = "";
        var frontAlgorithmIds = [];
        var algorithmid = "";
        var blockName = "";
        $.each(instance.getAllConnections(), function (idx, connection) {
            if (connection.targetId == document.getElementById('blockid').value) {
                $("#combination .uibox").each(function (idx, elem) {
                    var $elem = $(elem);
                    if (connection.sourceId == $elem.attr('id') && $elem.attr('dataId') != null) {
                        algorithmid = $elem.attr('dataId').split("_")[1];
                        blockName = $elem.children('.uitext').text();
                    }
                });
                frontAlgorithmIds.push({blockId: connection.sourceId, blockName: blockName, algorithmId: algorithmid});
            }
        });
        var qz_jsonData = JSON.stringify(frontAlgorithmIds);
        $("#frontAlgorithmIds").val(qz_jsonData);
        layer.open({
            type: 2,
            skin: 'layui-layer-lan',
            title: '任务输出配置',
            fix: false,
            scrollbar: false,
            shadeClose: false,
            maxmin: true,
            area: ['500px', '80%'],
            content: constUrl + 'views/task/set/output.action'
        });
    });
    /*保存*/
    var button_save = $('#button_save');
    button_save.click(function () {
        var taskNumber = $("#taskNumber").val();
        var lackMatch = false, lackInputConfig = false, lackParamsConfig = false, lackOutput = false, lackData = false,
            lackOther = false, isCreate = $("#taskid").val(), connects = [];
        $.each(instance.getAllConnections(), function (idx, connection) {
            connects.push({pageSourceId: connection.sourceId, pageTargetId: connection.targetId});
        });
        var blocks = [];
        $("#combination .uibox").each(function (idx, elem) {
            var $elem = $(elem);
            if ($elem.attr('dataid') != null) {
                var inco = $elem.children('.inputConfig').val(), paco = $elem.children('.paramsConfig').val(),
                    pacode = $elem.children('.paramsConfigDefault').val(), paramNum = $elem.children('.paramNum').val();
                if ((paco == "undefined" || paco == "") && paramNum != 0) {
                    lackParamsConfig = true;
                } else if (paramNum == 0) {
                } else {
                    var json_paco = eval("(" + paco + ")");
                    if (json_paco.length != taskNumber) {
                        lackMatch = true;
                    }
                }
                if (paramNum == 0) {
                    paco = "[]";
                }
                var json_paco = eval(paco);
                blocks.push({
                    dataId: $elem.attr('dataid').split("_")[1],
                    isAlgorithm: $elem.attr('dataid').split("_")[0],
                    blockId: $elem.attr('id'),
                    blockClass: $elem.attr('class').split(' ')[0],
                    blockName: $elem.children('.uitext').text(),
                    blockTitle: $elem.children('.uitext').attr("title"),
                    blockX: parseInt($elem.css("left")),
                    blockY: parseInt($elem.css("top")),
                    cpuNum: $elem.children('.cpuNum').val(),
                    paramNum: paramNum,
                    inputConfig: eval(inco),
                    paramsConfig: json_paco,
                    paramsConfigDefault: eval(pacode)
                });
            } else {
                blocks.push({
                    blockId: $elem.attr('id'),
                    blockClass: $elem.attr('class').split(' ')[0],
                    blockName: $elem.children('.uitext').text(),
                    blockX: parseInt($elem.css("left")),
                    blockY: parseInt($elem.css("top"))
                });
            }
        });
        let inputs = $("#input").val();
        var outputs = $("#output").val();
        if (outputs == "undefined" || outputs == "") {
            lackOutput = true;
        }
        var other = $("#other").val();
        if (other == "undefined" || data == "") {
            lackOther = true;
        }
        var post_jsondata = "{\"blocks\":" + JSON.stringify(blocks) + ",\"lines\":" + JSON.stringify(connects) + ",\"taskNumber\":" + taskNumber + ",\"inputs\":" + inputs + ",\"outputs\":" + outputs + ",\"other\":" + other + "}";
        $('#post_jsondata').val(post_jsondata);
        if (lackInputConfig) {
            layer.alert("初始算法输入文件尚未配置完成，保存任务失败！");
        } else if (lackParamsConfig) {
            layer.alert("算法参数信息尚未配置完成，保存任务失败！");
        } else if (lackMatch) {
            layer.alert("算法参数信息与任务数量不匹配，保存任务失败！");
        } else if (lackData) {
            layer.alert("任务外部输入文件尚未配置完成，保存任务失败！");
        } else if (lackOutput) {
            layer.alert("任务输出文件尚未配置完成，保存任务失败！");
        } else if (lackOther) {
            layer.alert("任务其他设置尚未配置完成，保存任务失败！");
        } else {
            if (isCreate == "") {/*layer弹出*/
                layer.ready(function () {
                    layer.open({
                        type: 2,
                        skin: 'layui-layer-lan',
                        title: '任务注册',
                        fix: false,
                        shadeClose: true,
                        maxmin: true,
                        area: ['400px', '410px'],
                        content: constUrl + 'views/task/create/save.action'
                    });
                });
            } else {
                layer.ready(function () {
                    layer.open({
                        type: 2,
                        skin: 'layui-layer-lan',
                        title: '任务修改',
                        fix: false,
                        scrollbar: false,
                        shadeClose: true,
                        maxmin: true,
                        area: ['400px', '270px'],
                        content: constUrl + 'views/task/create/alert.action'
                    });
                });
            }
        }
    });
    $('#container_b').resizable({
        handles: 'n', minHeight: 25, containment: $('#content'), resize: function (event, ui) {
            $('#task_info').height(ui.size.height - 25);
            $('#container_b').css("top", "");
            if (isTop) {
                if ($('#container_b').height() <= 595) {
                    $('#task_info_right_down').removeClass("glyphicon-chevron-down");
                    $('#task_info_right_down').addClass("glyphicon-chevron-up");
                    isTop = false;
                    $('#task_info_right_down').attr("id", "task_info_right_top");
                }
            } else {
                if ($('#container_b').height() >= 595) {
                    $('#task_info_right_top').removeClass("glyphicon-chevron-up");
                    $('#task_info_right_top').addClass("glyphicon-chevron-down");
                    isTop = true;
                    $('#task_info_right_top').attr("id", "task_info_right_down");
                }
            }
        }
    });
    /*显示控制显示页*/
    $("#task_info_control").on("click", "#task_info_right_top", function () {
        $('#container_b').animate({height: "597px"}, "slow");
        $('#container_b').css("top", "");
        $('#task_info').animate({height: "572px"}, "slow");
        $('#task_info_right_top').removeClass("glyphicon-chevron-up");
        $('#task_info_right_top').addClass("glyphicon-chevron-down");
        isTop = true;
        $('#task_info_right_top').attr("id", "task_info_right_down");
    });
    $("#task_info_control").on("click", "#task_info_right_down", function () {
        $('#container_b').animate({height: "225px"}, "slow");
        $('#container_b').css("top", "");
        $('#task_info').animate({height: "200px"}, "slow");
        $('#task_info_right_down').removeClass("glyphicon-chevron-down");
        $('#task_info_right_down').addClass("glyphicon-chevron-up");
        isTop = false;
        $('#task_info_right_down').attr("id", "task_info_right_top");
    });
    /*运行*/
    $('#button_start').click(function () {
        $('#button_start').attr("disabled", true);
        $('#button_start').css("display", "none");
        $('#button_continue').attr("disabled", true);
        $('#button_continue').css("display", "inline-block");
        $('#button_stop').attr("disabled", false);
        $('#button_over').attr("disabled", false);
        $('#button_save').attr("disabled", true);
        if (!isTaskStart) {
            layer.load(2);
            isTaskStart = true;
            var sjHash = Hash20();
            var taskId = $('#taskid').val();
            document.getElementById("taskhash").value = sjHash;
            $('#task_info_pre').html("");
            $.ajax({
                url: constUrl + "StartTask",
                type: 'post',
                data: {"taskId": taskId, "taskHash": sjHash},
                dataType: 'json',
                xhrFields: {withCredentials: true},
                crossDomain: true,
                success: function (response) {
                    layer.closeAll('loading');
                    console.log(new Date());
                    $('#task_info_pre').append("开始执行任务！\n");
                    isStart = true;
                    layer.alert("开始执行任务！");
                    $(".progress-bar").each(function (index, elem) {
                        var $elem = $(elem);
                        $elem.attr("style", "width: 0%");
                    });
                    console.log(new Date());
                    let cx_taskHash = document.getElementById("taskhash").value;
                    add_page_num += 1;
                    $.ajax({
                        url: constUrl + "GetBlockState",
                        type: 'post',
                        timeout: 60000,
                        data: {
                            "taskHash": cx_taskHash,
                            "onePageCount": 10,
                            "currentPage": 1,
                            "waitTime": 0
                        },
                        xhrFields: {withCredentials: true},
                        crossDomain: true,
                        dataType: 'json',
                        success: function (responseText) {
                            if (responseText.finishedRatio == 1) {
                                $('#task_info_pre').scrollTop($('#task_info_pre')[0].scrollHeight);
                                $('#button_start').attr("disabled", true);
                                $('#button_start').css("display", "none");
                                $('#button_continue').attr("disabled", true);
                                $('#button_continue').css("display", "inline-block");
                                $('#button_stop').attr("disabled", true);
                                $('#button_over').attr("disabled", true);
                                $('#button_save').attr("disabled", true);
                                isStart = false;
                            }
                            let temp_1_parent = $("#treeTable").treetable("node", "1");
                            $("#treeTable").treetable("unloadBranch", temp_1_parent);
                            var subTaskHash = responseText.result;
                            var orders = responseText.algorithmOrder;
                            let temp_i_parent = $("#treeTable").treetable("node", "1");
                            for (var i = 0; i < subTaskHash.length; i++) {
                                $("#treeTable").treetable("loadBranch", temp_i_parent, '<tr data-tt-id="1-' + parseInt(i + 1) + '" data-tt-parent-id="1" id="' + subTaskHash[i].taskHash + '_tr"><td>任务：' + parseInt(i + 1) + '</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>');
                                let temp_j_parent =  $("#treeTable").treetable("node", "1-" + parseInt(i + 1));
                                for (var j = 0; j < orders.length; j++) {
                                    $("#treeTable").treetable("loadBranch", temp_j_parent, '<tr data-tt-id="1-' + parseInt(i + 1) + '-' + parseInt(j + 1) + '" data-tt-parent-id="1-' + parseInt(i + 1) + '" id="' + subTaskHash[i].taskHash + '_' + orders[j].blockId + '_tr" task-id="' + subTaskHash[i].taskHash + '" block-id="' + orders[j].blockId + '"><td>算法名：' + orders[j].algorithmName + '</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>');
                                }
                            }
                            $("#treeTable").treetable("expandAll");
                            for (var i = 0; i < responseText.result.length; i++) {
                                var json = responseText.result[i];
                                if (json.state == "DONE") {
                                    $("#" + json.taskHash + "_tr").children('td').eq(6).html("完成");
                                    $("#" + json.taskHash + "_tr").addClass("am-success");
                                } else if (json.state == "ERROR") {
                                    $("#" + json.taskHash + "_tr").children('td').eq(6).html("失败");
                                    $("#" + json.taskHash + "_tr").addClass("am-danger");
                                } else if (json.state == "STOP") {
                                    $("#" + json.taskHash + "_tr").children('td').eq(6).html("终止");
                                    $("#" + json.taskHash + "_tr").addClass("am-danger");
                                } else if (json.state == "PAUSE") {
                                    $("#" + json.taskHash + "_tr").children('td').eq(6).html("暂停");
                                    $("#" + json.taskHash + "_tr").addClass("am-danger");
                                } else if (json.state == "RUN" || json.state == "PEND") {
                                } else {
                                }
                                console.log(json.detail);
                                if (json.detail != null) {
                                    for (var j = 0; j < json.detail.length; j++) {
                                        var jobJson = json.detail[j];
                                        if ($("#"+jobJson.id).length>0){
                                            $("#" + jobJson.id).children("td").eq(2).html(jobJson.name);
                                            $("#" + jobJson.id).children("td").eq(3).html(jobJson.commitTime);
                                            $("#" + jobJson.id).children("td").eq(4).html(jobJson.endTime);
                                            $("#" + jobJson.id).children("td").eq(5).html(jobJson.priority);
                                            if (jobJson.isSuccess == "DONE") {
                                                state = "成功";
                                                $("#" + jobJson.id).removeClass();
                                                $("#" + jobJson.id).addClass("am-primary");
                                            } else if (jobJson.isSuccess == "PAUSE") {
                                                state = "暂停";
                                                $("#" + jobJson.id).removeClass();
                                                $("#" + jobJson.id).addClass("am-active");
                                            } else if (jobJson.isSuccess == "STOP") {
                                                state = "终止";
                                                $("#" + jobJson.id).removeClass();
                                                $("#" + jobJson.id).addClass("am-warning");
                                            } else if (jobJson.isSuccess == "ERROR") {
                                                state = "失败";
                                                $("#" + jobJson.id).removeClass();
                                                $("#" + jobJson.id).addClass("am-danger");
                                            } else {
                                                state = "运行中";
                                                $("#" + jobJson.id).removeClass();
                                                $("#" + jobJson.id).addClass("am-danger");
                                            }
                                            $("#" + jobJson.id).children("td").eq(6).html(state);
                                        }
                                        else {
                                            var data_tt_parent_id = $("#" + json.taskHash + "_" + jobJson.blockId + "_tr").attr("data-tt-id");
                                            var state = "";
                                            var temp_tr = '';
                                            $("#"+jobJson.id).remove();
                                            if (jobJson.isSuccess == "DONE") {
                                                state = "成功";
                                                temp_tr = '<tr id="' + jobJson.id + '" data-tt-id="' + data_tt_parent_id + '-' + jobJson.jobIndex + '" data-tt-parent-id="' + data_tt_parent_id + '" class="am-primary" block-id="' + jobJson.blockId + '" task-id="' + json.taskHash + '">' + '<td>作业' + jobJson.jobIndex + '</td>' + '<td>' + jobJson.id + '</td>' + '<td>' + jobJson.name + '</td>' + '<td>' + jobJson.commitTime + '</td>' + '<td>' + jobJson.endTime + '</td>' + '<td>' + jobJson.priority + '</td>' + '<td>' + state + '</td>' + '<td><a href="javascript: void(0)" class="jobDetails">详情</a> <a href="javascript: void(0)" class="jobRefresh">刷新</a></td>' + '</tr>';
                                            } else if (jobJson.isSuccess == "PAUSE") {
                                                state = "暂停";
                                                temp_tr = '<tr id="' + jobJson.id + '" data-tt-id="' + data_tt_parent_id + '-' + jobJson.jobIndex + '" data-tt-parent-id="' + data_tt_parent_id + '" class="am-active" block-id="' + jobJson.blockId + '" task-id="' + json.taskHash + '">' + '<td>作业' + jobJson.jobIndex + '</td>' + '<td>' + jobJson.id + '</td>' + '<td>' + jobJson.name + '</td>' + '<td>' + jobJson.commitTime + '</td>' + '<td>' + jobJson.endTime + '</td>' + '<td>' + jobJson.priority + '</td>' + '<td>' + state + '</td>' + '<td><a href="javascript: void(0)" class="jobDetails">详情</a> <a href="javascript: void(0)" class="jobRefresh">刷新</a></td>' + '</tr>';
                                            } else if (jobJson.isSuccess == "STOP") {
                                                state = "终止";
                                                temp_tr = '<tr id="' + jobJson.id + '" data-tt-id="' + data_tt_parent_id + '-' + jobJson.jobIndex + '" data-tt-parent-id="' + data_tt_parent_id + '" class="am-warning" block-id="' + jobJson.blockId + '" task-id="' + json.taskHash + '">' + '<td>作业' + jobJson.jobIndex + '</td>' + '<td>' + jobJson.id + '</td>' + '<td>' + jobJson.name + '</td>' + '<td>' + jobJson.commitTime + '</td>' + '<td>' + jobJson.endTime + '</td>' + '<td>' + jobJson.priority + '</td>' + '<td>' + state + '</td>' + '<td><a href="javascript: void(0)" class="jobDetails">详情</a> <a href="javascript: void(0)" class="jobRefresh">刷新</a></td>' + '</tr>';
                                            } else if (jobJson.isSuccess == "ERROR") {
                                                state = "";
                                                temp_tr = '<tr id="' + jobJson.id + '" data-tt-id="' + data_tt_parent_id + '-' + jobJson.jobIndex + '" data-tt-parent-id="' + data_tt_parent_id + '" class="am-danger" block-id="' + jobJson.blockId + '" task-id="' + json.taskHash + '">' + '<td>作业' + jobJson.jobIndex + '</td>' + '<td>' + jobJson.id + '</td>' + '<td>' + jobJson.name + '</td>' + '<td>' + jobJson.commitTime + '</td>' + '<td>' + jobJson.endTime + '</td>' + '<td>' + jobJson.priority + '</td>' + '<td>' + state + '</td>' + '<td><a href="javascript: void(0)" class="jobDetails">详情</a> <a href="javascript: void(0)" class="jobRefresh">刷新</a></td>' + '</tr>';
                                            } else {
                                                state = "";
                                                temp_tr = '<tr id="' + jobJson.id + '" data-tt-id="' + data_tt_parent_id + '-' + jobJson.jobIndex + '" data-tt-parent-id="' + data_tt_parent_id + '" class="am-danger" block-id="' + jobJson.blockId + '" task-id="' + json.taskHash + '">' + '<td>作业' + jobJson.jobIndex + '</td>' + '<td>' + jobJson.id + '</td>' + '<td>' + jobJson.name + '</td>' + '<td>' + jobJson.commitTime + '</td>' + '<td>' + jobJson.endTime + '</td>' + '<td>' + jobJson.priority + '</td>' + '<td>' + state + '</td>' + '<td><a href="javascript: void(0)" class="jobDetails">详情</a> <a href="javascript: void(0)" class="jobRefresh">刷新</a></td>' + '</tr>';
                                            }
                                            var node = $("#treeTable").treetable("node", data_tt_parent_id);
                                            $("#treeTable").treetable("loadBranch", node, temp_tr);
                                            $("#treeTable").treetable("expandNode", "1");
                                            $("#treeTable").treetable("expandNode", data_tt_parent_id);
                                        }
                                        if (jobJson.isAlgorithmFinished == 1)
                                            isAlgorithmFinished(jobJson.blockId, jobJson.id)
                                    }
                                }
                            }
                            for (let ii = 0; ii<responseText.algorithmOrder.length; ii++){
                                isAllAlgorithmFinished(responseText.algorithmOrder[ii].blockId, responseText.algorithmOrder[ii].finishedRatio);
                            }
                            console.log(responseText.pageNum);
                            addPageNum(parseInt(responseText.pageNum));
                            paginationInit();
                            receiveJobs(1, 10, add_page_num);
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            if (textStatus == "timeout") {/*超时间*/
                                receiveJobs(1, 10, current_add_page_num);
                            }
                        }
                    })
                    communicate();
                },
                complete: function () {
                },
                error: function () {
                    isTaskStart = false;
                }
            });
        }
    });
    /*暂停*/
    $('#button_stop').click(function () {
        var pt_taskHash = document.getElementById("taskhash").value;
        $.ajax({
            url: constUrl + "PauseTask",
            type: 'post',
            data: {"taskHash": pt_taskHash},
            xhrFields: {withCredentials: true},
            crossDomain: true,
            success: function (responseText) {
                if (responseText == "true") {
                    $('#task_info_pre').append("暂停任务成功！");
                    $('#task_info_pre').scrollTop($('#task_info_pre')[0].scrollHeight);
                    $('#button_start').attr("disabled", true);
                    $('#button_start').css("display", "none");
                    $('#button_continue').attr("disabled", false);
                    $('#button_continue').css("display", "inline-block");
                    $('#button_stop').attr("disabled", true);
                    $('#button_over').attr("disabled", true);
                    $('#button_save').attr("disabled", true);
                    isStart = false;
                    layer.alert("暂停任务成功！");
                } else if (responseText == "error") {
                    $('#task_info_pre').append("任务运行出错！");
                    $('#task_info_pre').scrollTop($('#task_info_pre')[0].scrollHeight);
                    $('#button_start').attr("disabled", true);
                    $('#button_start').css("display", "none");
                    $('#button_continue').attr("disabled", true);
                    $('#button_continue').css("display", "inline-block");
                    $('#button_stop').attr("disabled", true);
                    $('#button_over').attr("disabled", true);
                    $('#button_save').attr("disabled", true);
                    isStart = false;
                    layer.alert("任务运行出错！");
                } else if (responseText == "finished") {
                    $('#task_info_pre').append("任务已完成！");
                    $('#task_info_pre').scrollTop($('#task_info_pre')[0].scrollHeight);
                    $('#button_start').attr("disabled", true);
                    $('#button_start').css("display", "none");
                    $('#button_continue').attr("disabled", true);
                    $('#button_continue').css("display", "inline-block");
                    $('#button_stop').attr("disabled", true);
                    $('#button_over').attr("disabled", true);
                    $('#button_save').attr("disabled", true);
                    isStart = false;
                    layer.alert("任务已完成！");
                }
            },
            complete: function () {
            },
            error: function () {
            }
        });
    });
    /*继续*/
    $('#button_continue').click(function () {
        var ct_taskHash = document.getElementById("taskhash").value;
        $.ajax({
            url: constUrl + "RestartTask",
            type: 'post',
            data: {"taskHash": ct_taskHash},
            xhrFields: {withCredentials: true},
            crossDomain: true,
            success: function (responseText) {
                if (responseText == "true") {
                    $('#task_info_pre').append("重启任务成功！");
                    $('#task_info_pre').scrollTop($('#task_info_pre')[0].scrollHeight);
                    $('#button_start').attr("disabled", true);
                    $('#button_start').css("display", "none");
                    $('#button_continue').attr("disabled", true);
                    $('#button_continue').css("display", "inline-block");
                    $('#button_stop').attr("disabled", false);
                    $('#button_over').attr("disabled", false);
                    $('#button_save').attr("disabled", true);
                    isStart = true;
                    communicate();
                    receiveJobs();
                    layer.alert("重启任务成功！");
                } else if (responseText == "error") {
                    $('#task_info_pre').append("任务运行出错！");
                    $('#task_info_pre').scrollTop($('#task_info_pre')[0].scrollHeight);
                    $('#button_start').attr("disabled", true);
                    $('#button_start').css("display", "none");
                    $('#button_continue').attr("disabled", true);
                    $('#button_continue').css("display", "inline-block");
                    $('#button_stop').attr("disabled", true);
                    $('#button_over').attr("disabled", true);
                    $('#button_save').attr("disabled", true);
                    isStart = false;
                    layer.alert("任务运行出错！");
                } else if (responseText == "finished") {
                    $('#task_info_pre').append("任务已完成！");
                    $('#task_info_pre').scrollTop($('#task_info_pre')[0].scrollHeight);
                    $('#button_start').attr("disabled", true);
                    $('#button_start').css("display", "none");
                    $('#button_continue').attr("disabled", true);
                    $('#button_continue').css("display", "inline-block");
                    $('#button_stop').attr("disabled", true);
                    $('#button_over').attr("disabled", true);
                    $('#button_save').attr("disabled", true);
                    isStart = false;
                    layer.alert("任务已完成！");
                }
            },
            complete: function () {
            },
            error: function () {
            }
        });
    });
    /*终止*/
    $('#button_over').click(function () {
        var ov_taskHash = document.getElementById("taskhash").value;
        $.ajax({
            url: constUrl + "ws/task/stop",
            type: 'post',
            data: {"taskHash": ov_taskHash},
            xhrFields: {withCredentials: true},
            crossDomain: true,
            success: function (responseText) {/* if (responseText == "true") {*/
                $('#task_info_pre').append("终止任务成功！");
                $('#task_info_pre').scrollTop($('#task_info_pre')[0].scrollHeight);
                $('#button_start').attr("disabled", false);
                $('#button_start').css("display", "inline-block");
                $('#button_continue').attr("disabled", true);
                $('#button_continue').css("display", "none");
                $('#button_stop').attr("disabled", true);
                $('#button_over').attr("disabled", true);
                $('#button_save').attr("disabled", true);
                isStart = false;
                layer.alert("终止任务成功！");/* } else if (responseText == "error") { $('#task_info_pre').append("任务运行出错！"); $('#task_info_pre').scrollTop($('#task_info_pre')[0].scrollHeight); $('#button_start').attr("disabled", true); $('#button_start').css("display", "none"); $('#button_continue').attr("disabled", true); $('#button_continue').css("display", "inline-block"); $('#button_stop').attr("disabled", true); $('#button_over').attr("disabled", true); $('#button_save').attr("disabled", true); isStart = true; layer.alert("任务运行出错！"); } else if (responseText == "finished") { $('#task_info_pre').append("任务已完成！"); $('#task_info_pre').scrollTop($('#task_info_pre')[0].scrollHeight); $('#button_start').attr("disabled", true); $('#button_start').css("display", "none"); $('#button_continue').attr("disabled", true); $('#button_continue').css("display", "inline-block"); $('#button_stop').attr("disabled", true); $('#button_over').attr("disabled", true); $('#button_save').attr("disabled", true); isStart = false; layer.alert("任务已完成！"); }*/
            },
            complete: function () {
            },
            error: function () {
            }
        });
    });
    $("#displayBoxRBtn").click(function () {
        $("#displayBoxRBtn").css("display", "none");
        $("#displayBoxLBtn").css("display", "inline-block");
        $("#displayBox").animate({width: '24px'});
    });
    $("#displayBoxLBtn").click(function () {
        $("#displayBoxLBtn").css("display", "none");
        $("#displayBoxRBtn").css("display", "inline-block");
        $("#displayBox").animate({width: '400px'});
    });
    $('img').on('mousedown', function (e) {
        e.preventDefault()
    });
});
var communicate = function () {
    if (isStart) {
        var cx_taskHash = document.getElementById("taskhash").value;
        $.ajax({
            url: constUrl + "GetNewestState",
            type: 'post',
            dataType: 'json',
            timeout: 60000,
            data: {"taskHash": cx_taskHash},
            xhrFields: {withCredentials: true},
            crossDomain: true,
            success: function (responseText) {
                for (var i = 0; i < responseText.length; i++) {
                    var rT = responseText[i].state;
                    if (rT == "" || rT == "finished") {
                    } else {
                        $('#task_info_pre').append(rT);
                        $('#task_info_pre').scrollTop($('#task_info_pre')[0].scrollHeight);
                    }
                }
                communicate();
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                if (textStatus == "timeout") {/*超时间*/
                    communicate();
                }
            }
        })
    } else {
    }
}
let receiveJobs = function (current_page, one_page_num, current_add_page_num) {
    if (isStart) {
        let cx_taskHash = document.getElementById("taskhash").value;
        $.ajax({
            url: constUrl + "GetBlockState",
            type: 'post',
            timeout: 60000,
            data: {
                "taskHash": cx_taskHash,
                "onePageCount": 10,
                "currentPage": parseInt(current_page),
                "waitTime": 5
            },
            xhrFields: {withCredentials: true},
            crossDomain: true,
            dataType: 'json',
            success: function (responseText) {
                if (current_add_page_num == add_page_num){
                    if (responseText.finishedRatio == 1) {/*$('#task_info_pre').append("批量任务执行完成！");*/
                        $('#task_info_pre').scrollTop($('#task_info_pre')[0].scrollHeight);
                        $('#button_start').attr("disabled", true);
                        $('#button_start').css("display", "none");
                        $('#button_continue').attr("disabled", true);
                        $('#button_continue').css("display", "inline-block");
                        $('#button_stop').attr("disabled", true);
                        $('#button_over').attr("disabled", true);
                        $('#button_save').attr("disabled", true);
                        isStart = false;
                    }
                    for (var i = 0; i < responseText.result.length; i++) {
                        var json = responseText.result[i];
                        if (json.state == "DONE") {
                            $("#" + json.taskHash + "_tr").children('td').eq(6).html("完成");
                            $("#" + json.taskHash + "_tr").addClass("am-success");
                        } else if (json.state == "ERROR") {
                            $("#" + json.taskHash + "_tr").children('td').eq(6).html("失败");
                            $("#" + json.taskHash + "_tr").addClass("am-danger");
                        } else if (json.state == "STOP") {
                            $("#" + json.taskHash + "_tr").children('td').eq(6).html("终止");
                            $("#" + json.taskHash + "_tr").addClass("am-danger");
                        } else if (json.state == "PAUSE") {
                            $("#" + json.taskHash + "_tr").children('td').eq(6).html("暂停");
                            $("#" + json.taskHash + "_tr").addClass("am-danger");
                        } else if (json.state == "RUN" || json.state == "PEND") {
                        } else {
                        }
                        if (json.detail != null) {
                            for (var j = 0; j < json.detail.length; j++) {
                                var jobJson = json.detail[j];
                                if ($("#"+jobJson.id).length>0){
                                    $("#" + jobJson.id).children("td").eq(2).html(jobJson.name);
                                    $("#" + jobJson.id).children("td").eq(3).html(jobJson.commitTime);
                                    $("#" + jobJson.id).children("td").eq(4).html(jobJson.endTime);
                                    $("#" + jobJson.id).children("td").eq(5).html(jobJson.priority);
                                    if (jobJson.isSuccess == "DONE") {
                                        state = "成功";
                                        $("#" + jobJson.id).removeClass();
                                        $("#" + jobJson.id).addClass("am-primary");
                                    } else if (jobJson.isSuccess == "PAUSE") {
                                        state = "暂停";
                                        $("#" + jobJson.id).removeClass();
                                        $("#" + jobJson.id).addClass("am-active");
                                    } else if (jobJson.isSuccess == "STOP") {
                                        state = "终止";
                                        $("#" + jobJson.id).removeClass();
                                        $("#" + jobJson.id).addClass("am-warning");
                                    } else if (jobJson.isSuccess == "ERROR") {
                                        state = "失败";
                                        $("#" + jobJson.id).removeClass();
                                        $("#" + jobJson.id).addClass("am-danger");
                                    } else {
                                        state = "运行中";
                                        $("#" + jobJson.id).removeClass();
                                        $("#" + jobJson.id).addClass("am-danger");
                                    }
                                    $("#" + jobJson.id).children("td").eq(6).html(state);
                                }
                                else {
                                    var data_tt_parent_id = $("#" + json.taskHash + "_" + jobJson.blockId + "_tr").attr("data-tt-id");
                                    var state = "";
                                    var temp_tr = '';
                                    $("#"+jobJson.id).remove();
                                    if (jobJson.isSuccess == "DONE") {
                                        state = "成功";
                                        temp_tr = '<tr id="' + jobJson.id + '" data-tt-id="' + data_tt_parent_id + '-' + jobJson.jobIndex + '" data-tt-parent-id="' + data_tt_parent_id + '" class="am-primary" block-id="' + jobJson.blockId + '" task-id="' + json.taskHash + '">' + '<td>作业' + jobJson.jobIndex + '</td>' + '<td>' + jobJson.id + '</td>' + '<td>' + jobJson.name + '</td>' + '<td>' + jobJson.commitTime + '</td>' + '<td>' + jobJson.endTime + '</td>' + '<td>' + jobJson.priority + '</td>' + '<td>' + state + '</td>' + '<td><a href="javascript: void(0)" class="jobDetails">详情</a> <a href="javascript: void(0)" class="jobRefresh">刷新</a></td>' + '</tr>';
                                    } else if (jobJson.isSuccess == "PAUSE") {
                                        state = "暂停";
                                        temp_tr = '<tr id="' + jobJson.id + '" data-tt-id="' + data_tt_parent_id + '-' + jobJson.jobIndex + '" data-tt-parent-id="' + data_tt_parent_id + '" class="am-active" block-id="' + jobJson.blockId + '" task-id="' + json.taskHash + '">' + '<td>作业' + jobJson.jobIndex + '</td>' + '<td>' + jobJson.id + '</td>' + '<td>' + jobJson.name + '</td>' + '<td>' + jobJson.commitTime + '</td>' + '<td>' + jobJson.endTime + '</td>' + '<td>' + jobJson.priority + '</td>' + '<td>' + state + '</td>' + '<td><a href="javascript: void(0)" class="jobDetails">详情</a> <a href="javascript: void(0)" class="jobRefresh">刷新</a></td>' + '</tr>';
                                    } else if (jobJson.isSuccess == "STOP") {
                                        state = "终止";
                                        temp_tr = '<tr id="' + jobJson.id + '" data-tt-id="' + data_tt_parent_id + '-' + jobJson.jobIndex + '" data-tt-parent-id="' + data_tt_parent_id + '" class="am-warning" block-id="' + jobJson.blockId + '" task-id="' + json.taskHash + '">' + '<td>作业' + jobJson.jobIndex + '</td>' + '<td>' + jobJson.id + '</td>' + '<td>' + jobJson.name + '</td>' + '<td>' + jobJson.commitTime + '</td>' + '<td>' + jobJson.endTime + '</td>' + '<td>' + jobJson.priority + '</td>' + '<td>' + state + '</td>' + '<td><a href="javascript: void(0)" class="jobDetails">详情</a> <a href="javascript: void(0)" class="jobRefresh">刷新</a></td>' + '</tr>';
                                    } else if (jobJson.isSuccess == "ERROR") {
                                        state = "";
                                        temp_tr = '<tr id="' + jobJson.id + '" data-tt-id="' + data_tt_parent_id + '-' + jobJson.jobIndex + '" data-tt-parent-id="' + data_tt_parent_id + '" class="am-danger" block-id="' + jobJson.blockId + '" task-id="' + json.taskHash + '">' + '<td>作业' + jobJson.jobIndex + '</td>' + '<td>' + jobJson.id + '</td>' + '<td>' + jobJson.name + '</td>' + '<td>' + jobJson.commitTime + '</td>' + '<td>' + jobJson.endTime + '</td>' + '<td>' + jobJson.priority + '</td>' + '<td>' + state + '</td>' + '<td><a href="javascript: void(0)" class="jobDetails">详情</a> <a href="javascript: void(0)" class="jobRefresh">刷新</a></td>' + '</tr>';
                                    } else {
                                        state = "";
                                        temp_tr = '<tr id="' + jobJson.id + '" data-tt-id="' + data_tt_parent_id + '-' + jobJson.jobIndex + '" data-tt-parent-id="' + data_tt_parent_id + '" class="am-danger" block-id="' + jobJson.blockId + '" task-id="' + json.taskHash + '">' + '<td>作业' + jobJson.jobIndex + '</td>' + '<td>' + jobJson.id + '</td>' + '<td>' + jobJson.name + '</td>' + '<td>' + jobJson.commitTime + '</td>' + '<td>' + jobJson.endTime + '</td>' + '<td>' + jobJson.priority + '</td>' + '<td>' + state + '</td>' + '<td><a href="javascript: void(0)" class="jobDetails">详情</a> <a href="javascript: void(0)" class="jobRefresh">刷新</a></td>' + '</tr>';
                                    }
                                    var node = $("#treeTable").treetable("node", data_tt_parent_id);
                                    $("#treeTable").treetable("loadBranch", node, temp_tr);
                                    $("#treeTable").treetable("expandNode", "1");
                                    $("#treeTable").treetable("expandNode", data_tt_parent_id);
                                }
                                if (jobJson.isAlgorithmFinished == 1)
                                    isAlgorithmFinished(jobJson.blockId, jobJson.id)
                            }
                        }
                    }
                    for (let ii = 0; ii<responseText.algorithmOrder.length; ii++){
                        isAllAlgorithmFinished(responseText.algorithmOrder[ii].blockId, responseText.algorithmOrder[ii].finishedRatio);
                    }
                    receiveJobs(current_page, one_page_num, current_add_page_num);
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                if (textStatus == "timeout") {/*超时间*/
                    receiveJobs(current_page, one_page_num, current_add_page_num);
                }
            }
        })
    } else {
    }
}
$(function () {
    paginationInit();
});
var paginationMaxLength = 8;/*分页栏的最大显示条数*/
var onlyOnePageIsShow = true;/*只有一页的时候是否显示*/
function paginationInit() {
    $('[am-pagination =pagination_new ]').each(function () {
        initPagination($(this));
    });
}

function initPagination(element) {
    element.html('');
    var pagenumber = element.attr('pagenumber');
    var totalpage = element.attr('totalpage');
    var pMaxLength = element.attr('paginationMaxLength');
    var onePageIsShow = element.attr('onlyOnePageIsShow');/* console.log(totalpage)*/
    if (isNeedPagination(Number(totalpage), onePageIsShow)) {
        var content = '<ul class="am-pagination am-pagination-centered"><li value="0"><a href="javascript:void(0);">«</a></li>';
        for (var i = 1; i <= totalpage; i++) {
            content += '<li value="' + i + '"><a href="javascript:void(0);">' + i + '</a></li>'
        }
        content += '<li value="-1"><a href="javascript:void(0);">»</a></li></ul>';
        element.append(content);
        element.children('ul').children('li[value=' + pagenumber + ']').attr('class', 'am-active');
        setDisplayMaxLength(element, pMaxLength);
        addClickListener(element);
    }
}

function setDisplayMaxLength(element, len) {
    var currentpage = Number(element.attr('pagenumber'));
    var totoalpage = Number(element.attr('totalpage'));
    if (checkParamIsPositiveInteger(len)) {
        len = Number(len);
    } else {
        len = paginationMaxLength;
    }
    if (len < totoalpage) {
        var temp1 = parseInt((len - 1) / 2);
        var temp2 = parseInt(len / 2);
        if (temp1 < temp2) {
            var leftstart = currentpage - temp1;
            var rightend = currentpage + temp1 + 1;
        } else {
            var leftstart = currentpage - temp1;
            var rightend = currentpage + temp1;
        }
        if (leftstart < 1) {
            rightend += (1 - leftstart);
            leftstart = 1;
        }
        if (rightend > totoalpage) {
            if (leftstart > 1) {
                leftstart -= (rightend - totoalpage);
            }
            rightend = totoalpage;
        }
        if (leftstart < 1) {
            leftstart = 1
        }
        while (leftstart > 1) {
            element.children('ul').children('li[value = ' + (--leftstart) + ']').css('display', 'none');
        }
        while (rightend < totoalpage) {
            element.children('ul').children('li[value = ' + (++rightend) + ']').css('display', 'none');
        }
    }
}

function isNeedPagination(totalpage, settingfromHTML) {
    var condition;
    if (settingfromHTML == "true") {
        condition = true;
    } else if (settingfromHTML == 'false') {
        condition = false;
    } else {
        condition = onlyOnePageIsShow;
    }
    if (condition && totalpage < 1) {
        return false;
    } else if (!condition && totalpage <= 1) {
        return false;
    }
    return true;
}
/*根据页面pagenumber、my_totoalpage更新分页，参数element传的是分页的容器*/
function addClickListener(element) {
    element.children('ul').children('li').bind('click', function () {
        var temp = Number($(this).attr('value'));
        var pagenumber = Number($(this).parent().parent().attr('pagenumber'));
        var totalpage = Number($(this).parent().parent().attr('totalpage'));
        if (temp == 0) {
            temp = pagenumber - 1;
        } else if (temp == -1) {
            temp = pagenumber + 1;
        }
        if (temp != pagenumber && temp != 0 && temp <= totalpage) {
            $(this).parent().parent().attr('pagenumber', temp);
            paginationClick(element.attr("id"));
            initPagination(element);
        }
        return false;
    })
}

function checkParamIsPositiveInteger(param) {
    var reg = /^[1-9]+[0-9]*]*$/;
    return reg.test(param);
}
/*用户需要自己实现的点击事件，参数为分页容器的id*/
function paginationClick(pagination_id) {
    let cx_taskHash = document.getElementById("taskhash").value;
    var pagenumber = $('#' + pagination_id + '').attr('pagenumber');
    add_page_num += 1;
    $.ajax({
        url: constUrl + "GetBlockState",
        type: 'post',
        timeout: 60000,
        data: {
            "taskHash": cx_taskHash,
            "onePageCount": 10,
            "currentPage": parseInt(pagenumber),
            "waitTime": 0
        },
        xhrFields: {withCredentials: true},
        crossDomain: true,
        dataType: 'json',
        success: function (responseText) {
            if (responseText.finishedRatio == 1) {
                $('#task_info_pre').scrollTop($('#task_info_pre')[0].scrollHeight);
                $('#button_start').attr("disabled", true);
                $('#button_start').css("display", "none");
                $('#button_continue').attr("disabled", true);
                $('#button_continue').css("display", "inline-block");
                $('#button_stop').attr("disabled", true);
                $('#button_over').attr("disabled", true);
                $('#button_save').attr("disabled", true);
                isStart = false;
            }
            let temp_1_parent = $("#treeTable").treetable("node", "1");
            $("#treeTable").treetable("unloadBranch", temp_1_parent);
            var subTaskHash = responseText.result;
            var orders = responseText.algorithmOrder;
            let temp_i_parent = $("#treeTable").treetable("node", "1");
            for (var i = 0; i < subTaskHash.length; i++) {
                $("#treeTable").treetable("loadBranch", temp_i_parent, '<tr data-tt-id="1-' + parseInt((parseInt(pagenumber) - 1) * 10 + i + 1) + '" data-tt-parent-id="1" id="' + subTaskHash[i].taskHash + '_tr"><td>任务：' + ((parseInt(pagenumber) - 1) * 10 + i + 1) + '</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>');
                let temp_j_parent =  $("#treeTable").treetable("node", "1-" + parseInt((parseInt(pagenumber) - 1) * 10 + i + 1));
                for (var j = 0; j < orders.length; j++) {
                    $("#treeTable").treetable("loadBranch", temp_j_parent, '<tr data-tt-id="1-' + parseInt((parseInt(pagenumber) - 1) * 10 + i + 1) + '-' + parseInt(j + 1) + '" data-tt-parent-id="1-' + parseInt((parseInt(pagenumber) - 1) * 10 + i + 1) + '" id="' + subTaskHash[i].taskHash + '_' + orders[j].blockId + '_tr" task-id="' + subTaskHash[i].taskHash + '" block-id="' + orders[j].blockId + '"><td>算法名：' + orders[j].algorithmName + '</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>');
                }
            }
            $("#treeTable").treetable("expandAll");
            for (var i = 0; i < responseText.result.length; i++) {
                var json = responseText.result[i];
                if (json.state == "DONE") {
                    $("#" + json.taskHash + "_tr").children('td').eq(6).html("完成");
                    $("#" + json.taskHash + "_tr").addClass("am-success");
                } else if (json.state == "ERROR") {
                    $("#" + json.taskHash + "_tr").children('td').eq(6).html("失败");
                    $("#" + json.taskHash + "_tr").addClass("am-danger");
                } else if (json.state == "STOP") {
                    $("#" + json.taskHash + "_tr").children('td').eq(6).html("终止");
                    $("#" + json.taskHash + "_tr").addClass("am-danger");
                } else if (json.state == "PAUSE") {
                    $("#" + json.taskHash + "_tr").children('td').eq(6).html("暂停");
                    $("#" + json.taskHash + "_tr").addClass("am-danger");
                } else if (json.state == "RUN" || json.state == "PEND") {
                } else {
                }
                if (json.detail != null) {
                    for (var j = 0; j < json.detail.length; j++) {
                        var jobJson = json.detail[j];
                        if ($("#"+jobJson.id).length>0){
                            $("#" + jobJson.id).children("td").eq(2).html(jobJson.name);
                            $("#" + jobJson.id).children("td").eq(3).html(jobJson.commitTime);
                            $("#" + jobJson.id).children("td").eq(4).html(jobJson.endTime);
                            $("#" + jobJson.id).children("td").eq(5).html(jobJson.priority);
                            if (jobJson.isSuccess == "DONE") {
                                state = "成功";
                                $("#" + jobJson.id).removeClass();
                                $("#" + jobJson.id).addClass("am-primary");
                            } else if (jobJson.isSuccess == "PAUSE") {
                                state = "暂停";
                                $("#" + jobJson.id).removeClass();
                                $("#" + jobJson.id).addClass("am-active");
                            } else if (jobJson.isSuccess == "STOP") {
                                state = "终止";
                                $("#" + jobJson.id).removeClass();
                                $("#" + jobJson.id).addClass("am-warning");
                            } else if (jobJson.isSuccess == "ERROR") {
                                state = "失败";
                                $("#" + jobJson.id).removeClass();
                                $("#" + jobJson.id).addClass("am-danger");
                            } else {
                                state = "运行中";
                                $("#" + jobJson.id).removeClass();
                                $("#" + jobJson.id).addClass("am-danger");
                            }
                            $("#" + jobJson.id).children("td").eq(6).html(state);
                        }
                        else {
                            var data_tt_parent_id = $("#" + json.taskHash + "_" + jobJson.blockId + "_tr").attr("data-tt-id");
                            var state = "";
                            var temp_tr = '';
                            $("#"+jobJson.id).remove();
                            if (jobJson.isSuccess == "DONE") {
                                state = "成功";
                                temp_tr = '<tr id="' + jobJson.id + '" data-tt-id="' + data_tt_parent_id + '-' + jobJson.jobIndex + '" data-tt-parent-id="' + data_tt_parent_id + '" class="am-primary" block-id="' + jobJson.blockId + '" task-id="' + json.taskHash + '">' + '<td>作业' + jobJson.jobIndex + '</td>' + '<td>' + jobJson.id + '</td>' + '<td>' + jobJson.name + '</td>' + '<td>' + jobJson.commitTime + '</td>' + '<td>' + jobJson.endTime + '</td>' + '<td>' + jobJson.priority + '</td>' + '<td>' + state + '</td>' + '<td><a href="javascript: void(0)" class="jobDetails">详情</a> <a href="javascript: void(0)" class="jobRefresh">刷新</a></td>' + '</tr>';
                            } else if (jobJson.isSuccess == "PAUSE") {
                                state = "暂停";
                                temp_tr = '<tr id="' + jobJson.id + '" data-tt-id="' + data_tt_parent_id + '-' + jobJson.jobIndex + '" data-tt-parent-id="' + data_tt_parent_id + '" class="am-active" block-id="' + jobJson.blockId + '" task-id="' + json.taskHash + '">' + '<td>作业' + jobJson.jobIndex + '</td>' + '<td>' + jobJson.id + '</td>' + '<td>' + jobJson.name + '</td>' + '<td>' + jobJson.commitTime + '</td>' + '<td>' + jobJson.endTime + '</td>' + '<td>' + jobJson.priority + '</td>' + '<td>' + state + '</td>' + '<td><a href="javascript: void(0)" class="jobDetails">详情</a> <a href="javascript: void(0)" class="jobRefresh">刷新</a></td>' + '</tr>';
                            } else if (jobJson.isSuccess == "STOP") {
                                state = "终止";
                                temp_tr = '<tr id="' + jobJson.id + '" data-tt-id="' + data_tt_parent_id + '-' + jobJson.jobIndex + '" data-tt-parent-id="' + data_tt_parent_id + '" class="am-warning" block-id="' + jobJson.blockId + '" task-id="' + json.taskHash + '">' + '<td>作业' + jobJson.jobIndex + '</td>' + '<td>' + jobJson.id + '</td>' + '<td>' + jobJson.name + '</td>' + '<td>' + jobJson.commitTime + '</td>' + '<td>' + jobJson.endTime + '</td>' + '<td>' + jobJson.priority + '</td>' + '<td>' + state + '</td>' + '<td><a href="javascript: void(0)" class="jobDetails">详情</a> <a href="javascript: void(0)" class="jobRefresh">刷新</a></td>' + '</tr>';
                            } else if (jobJson.isSuccess == "ERROR") {
                                state = "";
                                temp_tr = '<tr id="' + jobJson.id + '" data-tt-id="' + data_tt_parent_id + '-' + jobJson.jobIndex + '" data-tt-parent-id="' + data_tt_parent_id + '" class="am-danger" block-id="' + jobJson.blockId + '" task-id="' + json.taskHash + '">' + '<td>作业' + jobJson.jobIndex + '</td>' + '<td>' + jobJson.id + '</td>' + '<td>' + jobJson.name + '</td>' + '<td>' + jobJson.commitTime + '</td>' + '<td>' + jobJson.endTime + '</td>' + '<td>' + jobJson.priority + '</td>' + '<td>' + state + '</td>' + '<td><a href="javascript: void(0)" class="jobDetails">详情</a> <a href="javascript: void(0)" class="jobRefresh">刷新</a></td>' + '</tr>';
                            } else {
                                state = "";
                                temp_tr = '<tr id="' + jobJson.id + '" data-tt-id="' + data_tt_parent_id + '-' + jobJson.jobIndex + '" data-tt-parent-id="' + data_tt_parent_id + '" class="am-danger" block-id="' + jobJson.blockId + '" task-id="' + json.taskHash + '">' + '<td>作业' + jobJson.jobIndex + '</td>' + '<td>' + jobJson.id + '</td>' + '<td>' + jobJson.name + '</td>' + '<td>' + jobJson.commitTime + '</td>' + '<td>' + jobJson.endTime + '</td>' + '<td>' + jobJson.priority + '</td>' + '<td>' + state + '</td>' + '<td><a href="javascript: void(0)" class="jobDetails">详情</a> <a href="javascript: void(0)" class="jobRefresh">刷新</a></td>' + '</tr>';
                            }
                            var node = $("#treeTable").treetable("node", data_tt_parent_id);
                            $("#treeTable").treetable("loadBranch", node, temp_tr);
                            $("#treeTable").treetable("expandNode", "1");
                            $("#treeTable").treetable("expandNode", data_tt_parent_id);
                        }
                        if (jobJson.isAlgorithmFinished == 1)
                            isAlgorithmFinished(jobJson.blockId, jobJson.id)
                    }
                }
            }
            for (let ii = 0; ii<responseText.algorithmOrder.length; ii++){
                isAllAlgorithmFinished(responseText.algorithmOrder[ii].blockId, responseText.algorithmOrder[ii].finishedRatio);
            }
            receiveJobs(parseInt(pagenumber), 10, add_page_num);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            if (textStatus == "timeout") {/*超时间*/
                receiveJobs(parseInt(pagenumber), 10, current_add_page_num);
            }
        }
    })
}
function addPageNum(num) {
    $('[am-pagination = pagination_new ]').attr("totalpage", num);
}